<template>
  <div>
    <el-select style="display: block;" :size="size" v-model="value" placeholder="选择人员" clearable @change="changeValue"
               @clear="changeValue">
      <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"/>
    </el-select>
  </div>
</template>

<script>
import {isNotNull} from "@/util/common-util";
import {getDeptByName} from "@/api/business/dept-user";

export default {
  name: "app-dept-user-select",
  props: {
    deptName: {
      type: String,
      default: ''
    },
    size: {
      type: String,
      default: 'small'
    }
  },
  data() {
    return {
      options: [],
      value: ''
    }
  },
  created() {
    this.initOptions(() => {
      if (isNotNull(this.initValue)) {
        this.value = this.initValue
      }
    })
  },
  methods: {
    initOptions(success) {

      getDeptByName(this.deptName).then(res => {
        console.log(res, 444)
      })

      this.options = [{
        label: '用户1',
        value: '用户1'
      }, {
        label: '用户2',
        value: '用户2'
      }]
      success && success()
    },
    changeValue() {
      this.$emit('change', this.value)
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
